$(function() {
    $("#submit_data").click(function(){
    
    var sl_num = $("#sl_num").val();//its only number...
    var retailer_name = $("#retailer_name").val();
    var sim_num = $("#sim_no").val();//only numbers...
    var dob = $("#idob").val();//date formate is dd/mm/yyyy otherthan dis need to give error...
    var cust_name = $("#cust_name").val();
    var fat_name = $("#father_name").val();
    var poi1 = $("#poi_num1").val();
    var poa2 = $("#poi_num2").val();
    var doc_num = $("#doc_addr_num").val();
    var doc_cross = $("#doc_addr_cross").val();
    var doc_area = $("#doc_area").val();
    var doc_city = $("#doc_city").val();
    var doc_pin = $("#doc_pin").val();
    
    var alt_num = $("#alt_num").val();
    var alt_cross = $("#alt_cross").val();
    var alt_area = $("#alt_area").val();
    var alt_city = $("#alt_city").val();
    var alt_pin = $("#alt_pin").val();
    var nope = $("#nop").val();
    var bld_rgn = $("#bld_reg").val();
    
    var doc_phone1 = $("#loc_ph1").val();
    var doc_phone2 = $("#loc_ph2").val();
    var cont_person = $("#cont_person").val();
    
    
    
    
    if(nope == "")
    {
        alert("NOP cannot be empty");
        $("#nop").focus();return false;
    }
        
      if(sl_num == "")
      {
         alert("Sl Number cannot be empty");
          $("#sl_num").focus();return false;
      }
      
      if(retailer_name == "")
      {
          alert("Retailer Name cannot be empty");
          $("#retailer_name").focus();
          return false;
      }
      
      if(sim_num == "")
      {
           alert("Sim Number cannot be empty");
           $("#sim_no").focus();
           return false;
           
      }
      
      if(dob == "")
      {
            alert("Please enter date of birth ");
            $("#idob").focus();
            return false;
      }
   
   	
      
      if(cust_name == "" || cust_name == "only text and hypen is allowed" )
      {
            alert("Please enter customer name");
            $("#cust_name").focus();
            return false; 
      }
    
      if( fat_name == "" || fat_name == "only text and hypen is allowed" )
      {
           alert("Please enter father name");
           $("#father_name").focus();
           return false; 
      }
      
      if( poi1 == "" || poi1 == "No Special Character, only alpha/numeric")
      {
            alert("Please enter poi number");
            $("#poi_num1").focus();
            return false;  
      }
      
      if(poa2 == "" || poa2 == "No Special Character, only alpha/numeric")
      {
            alert("Please enter poa number");
            $("#poi_num2").focus();
            return false;  
      }
      if( doc_num == "" || doc_num == "Door No/Flat No/House No")
      {
           alert("Please enter document address number!");
           $("#doc_addr_num").focus();
           return false;  
      }
      if( doc_cross == "" || doc_cross == "Cross,Main Stage,Block")
      {
          alert("Please enter document address cross field!");
          $("#doc_addr_cross").focus();
          return false; 
      }
      if(doc_area == "")
      {
          alert("Please enter document address area field!");
          $("#doc_area").focus();
          return false;  
      }
      if(doc_city == "")
      {
          alert("Please enter document address city name field!");
          $("#doc_city").focus();
          return false; 
      }
      if(doc_pin == "")
      {
          alert("Please enter document address pincode field!");
          $("#doc_pin").focus();
          return false; 
      }
      
      var ref_addr_num = $("#loc_addr_num").val();
      var ref_addr_crs = $("#loc_addr_cross").val();
      var ref_city = $("#loc_city").val();
      var ref_area = $("#loc_area").val();
      var ref_pin = $("#loc_pin").val(); 
     
      if ($('#same_loc').is(":not(':checked')")) { 
      
              if(alt_num == "" || alt_num == "Door No/Flat No/House No")
              {
                  alert("Please enter alternate address number !");
                  $("#alt_num").focus();
                  return false;  
              }
              
              if(alt_cross == "" || alt_cross == "Cross,Main Stage,Block")
              {
                  alert("Please enter alternate address cross !");
                  $("#alt_cross").focus();
                  return false; 
              }
              if(alt_area == "")
              {
                  alert("Please enter alternate address area !");
                  $("#alt_area").focus();
                  return false;  
              }
              if(alt_city == "")
              {
                  alert("Please enter alternate city name !");
                  $("#alt_city").focus();
                  return false; 
              }
              if(alt_pin == "")
              {
                  alert("Please enter alternate pincode !");
                  $("#alt_pin").focus();
                  return false; 
              }
              
           }   
           
           
    });
  });
  
  
  $(document).ready(function(){

	$("#doc_state_name").focusout(function(){
		$("#doc_city_input").focus();return true;	
		});
	
	
	$("#idob").keypress(function(e){
    	
    	var dob = $(this).val();
    	
    	if(dob.length>10)
    	{
    		return false;
    		$(this).focus();
    	}
    	
      	
    });
    
    
     $("#sl_num").keypress(function(e){
    	
    if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  	{
    //display error message
   // alert("Only numbers");
    $(this).focus();
    return false;
  	}
  	
    });
    
    $("#sl_num").keypress(function(e){
    	
    if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  	{
	  
	    $(this).focus();
	    return false;
  	}
  	
    });
      
     $("#retailer_name").keypress(function (e)
	{
		if(e.which == 32 )
	  	{
	  			$(this).focus();
		   		return true;
		 }
		   
	  	if( e.which!=8 && e.which!=0 && (e.which<65 || e.which>122))
	  	{
	    		$(this).focus();
		   		return false;
		    	
	  	}
	  	
	  	if(e.which == 91 )
		  	{
		  			$(this).focus();
			   		return false;
			 }
			 
		if(e.which == 92 )
		  	{
		  			$(this).focus();
			   		return false;
			 }
			 
		if(e.which == 93 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
			 
		if(e.which == 94 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
		if(e.which == 95 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
			 
		if(e.which == 96 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
	});
        
    $("#cust_name").keypress(function (e)
	{
		if(e.which == 32 )
	  	{
	  			$(this).focus();
		   		return true;
		 }
		   
	  	if( e.which!=8 && e.which!=0 && (e.which<65 || e.which>122))
	  	{
	    		$(this).focus();
		   		return false;
		    	
	  	}
	  	
	  	if(e.which == 91 )
		  	{
		  			$(this).focus();
			   		return false;
			 }
			 
		if(e.which == 92 )
		  	{
		  			$(this).focus();
			   		return false;
			 }
			 
		if(e.which == 93 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
			 
		if(e.which == 94 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
		if(e.which == 95 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
			 
		if(e.which == 96 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
	});
	
    $("#father_name").keypress(function (e)
	{
		if(e.which == 32 )
	  	{
	  			$(this).focus();
		   		return true;
		 }
		   
	  	if( e.which!=8 && e.which!=0 && (e.which<65 || e.which>122))
	  	{
	    		$(this).focus();
		   		return false;
		    	
	  	}
	  	
	  	if(e.which == 91 )
		  	{
		  			$(this).focus();
			   		return false;
			 }
			 
		if(e.which == 92 )
		  	{
		  			$(this).focus();
			   		return false;
			 }
			 
		if(e.which == 93 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
			 
		if(e.which == 94 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
		if(e.which == 95 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
			 
		if(e.which == 96 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
	});
	
	$("#ref_name").keypress(function (e)
	{
		if(e.which == 32 )
	  	{
	  			$(this).focus();
		   		return true;
		 }
		   
	  	if( e.which!=8 && e.which!=0 && (e.which<65 || e.which>122))
	  	{
	    		$(this).focus();
		   		return false;
		    	
	  	}
	  	
	  	if(e.which == 91 )
		  	{
		  			$(this).focus();
			   		return false;
			 }
			 
		if(e.which == 92 )
		  	{
		  			$(this).focus();
			   		return false;
			 }
			 
		if(e.which == 93 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
			 
		if(e.which == 94 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
		if(e.which == 95 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
			 
		if(e.which == 96 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
	});
	
	 $("#cont_person").keypress(function (e)
	{
		if(e.which == 32 )
	  	{
	  			$(this).focus();
		   		return true;
		 }
		   
	  	if( e.which!=8 && e.which!=0 && (e.which<65 || e.which>122))
	  	{
	    		$(this).focus();
		   		return false;
		    	
	  	}
	  	
	  	if(e.which == 91 )
		  	{
		  			$(this).focus();
			   		return false;
			 }
			 
		if(e.which == 92 )
		  	{
		  			$(this).focus();
			   		return false;
			 }
			 
		if(e.which == 93 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
			 
		if(e.which == 94 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
		if(e.which == 95 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
			 
		if(e.which == 96 )
		  	{
		  			$(this).focus();
			   		return false;
			 }	 
	});
	
    $("#loc_ph1").keypress(function (e)
	{

  //if the letter is not digit then display error and don't type anything
	  	if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
	  	{
	    //display error message
	   // alert("Only numbers");
	    $(this).focus();
	    return false;
	  	}
	});
	
	$("#loc_ph2").keypress(function (e)
	{

  //if the letter is not digit then display error and don't type anything
  	if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  	{
    //display error message
   // alert("Only numbers");
    $(this).focus();
    return false;
  	}
  	
 });
 
 $("#ref_ph").keypress(function (e)
	{

  //if the letter is not digit then display error and don't type anything
  	if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  	{
    //display error message
   // alert("Only numbers");
    $(this).focus();
    return false;
  	}
  	
 });


	$("#bld_reg").keypress(function (e)
	{

  //if the letter is not digit then display error and don't type anything
  	if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  	{
    //display error message
   // alert("Only numbers");
    $(this).focus();
    return false;
  	}


	});
	
//for date selection...

/*
 
 $("#retailer_name").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
   // alert("Only numbers");
    $("#nop").focus();
    return false;
  }
});
   */
$("#nop").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
   // alert("Only numbers");
    $("#nop").focus();
    return false;
  }
});
    
$("#alt_pin").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
   // alert("Only numbers");
   	$("#alt_pin").focus();
    return false;
  }
});

$("#loc_pin").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
   // alert("Only numbers");
   $("#loc_pin").focus();
    return false;
  }
});

$("#doc_pin").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
   // alert("Only numbers");
   $("#doc_pin").focus();
    return false;
  }
});

$("#sim_no").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
   
   $("#sim_no").focus();
    return false;
  }
});

});
